/**
 * @Description: 预售设置
 * @author ourslookAdmin
 * @date 2019-09-02 11:34:08
 */
import React, {Fragment} from 'react';
import {
  Button,
  Card,
  Checkbox,
  Col,
  Divider,
  Form,
  Input,
  InputNumber,
  Radio,
  Row,
  Select,
  Spin,
  Tag,
  TreeSelect,
  BackTop, Tooltip, Icon, DatePicker,
} from 'antd';
import {formatMessage, FormattedMessage} from 'umi/locale';
import moment from 'moment';
import 'antd/dist/antd.css';
import PropTypes from 'prop-types';
import {connect} from 'dva';
import {requestLists, requestPromise} from '@/utils/request';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import BaseForm from '../../../components/ourslook/BaseForm';
import ETable from '../../../components/ourslook/ETable';
import {getWebPath} from '../../../utils/request';
import uiUtils, {hasPermission, rulesReg, rulesRemote} from '../../../utils/uiUtils';
import styles from '../../../utils/ourslook.less';
import Ellipsis from '../../../components/ourslook/Ellipsis';

const { MonthPicker , RangePicker} = DatePicker;
const FormItem = Form.Item;
const Option = Select.Option;
const RadioGroup = Radio.Group;
const TextArea = Input.TextArea;
const Password = Input.Password;
const CheckboxGroup = Checkbox.Group;

const getValue = obj =>
  Object.keys(obj)
    .map(key => obj[key])
    .join(',');

@connect(() => ({}))
class MallProductPreSale extends React.Component {
  params = {
    page: 1,
    limit: 10,
  };

  formItemLayout = {
    labelCol: {span: 5},
    wrapperCol: {span: 19},
  };

  /**
   * https://ant-design.gitee.io/components/table-cn/
   *
   * 需要指定 column 的 width 属性，否则列头和内容可能不对齐。（必须留一列不设宽度或者minWidth以适应弹性布局）
   * 建议指定 scroll.x 为大于表格宽度的固定值或百分比。注意，且非固定列宽度之和不要超过 scroll.x, 一般无table正常展开的宽度
   * 未知长度字段或者字符特别多的字段不要放置在列表
   */
  columns = [
    {
      title: '',
      width: 30,
      align: 'center',
      fixed: 'left',
      render: (value, record, index) => index + 1,
    },
    {title: '商品名称', dataIndex: 'productName', width: 150, align: 'center', key: 'productName',
      render: (value, record, index) => (
        <Tooltip title={value}>
          <Ellipsis length={20}>
            {value}
          </Ellipsis>
        </Tooltip>
      ),
    },
    {title: '预售类型', dataIndex: 'preSaleType', width: 120, align: 'center', key: 'pre_sale_type',
      render: (value) => {
        let preSaleTypeName = '-';
        if (value === 0) {
          preSaleTypeName = '全款预售';
        }else if (value === 1) {
          preSaleTypeName = '定金预售';
        }
        return preSaleTypeName;
      },
    },
    {title: '发货类型', dataIndex: 'preEtdType', width: 120,align: 'center', key: 'pre_etd_type',
      render: (value) => {
        let preEtdTypeName = '-';
        if (value === 0) {
          preEtdTypeName = '指定日期发货';
        }else if (value === 1) {
          preEtdTypeName = 'X天后发货';
        }
        return preEtdTypeName;
      },
    },
    {
      title: '定金开始时间',
      dataIndex: 'presSaleStart',
      width: 120,
      align: 'center',
      key: 'pres_sale_start'
    },
    {
      title: '定金结束时间',
      dataIndex: 'presSaleEnd',
      width: 120,
      align: 'center',
      key: 'pres_sale_end'
    },
    {
      title: '尾款开始时间',
      dataIndex: 'presBalanceStart',
      width: 120,
      align: 'center',
      key: 'pres_balance_start'
    },
    {
      title: '尾款结束时间',
      dataIndex: 'presBalanceEnd',
      align: 'center',
      key: 'pres_balance_end'
    },
    {
      title: '操作',
      dataIndex: '',
      width: 150,
      align: 'center',
      fixed: 'right',
      render: (value, record, index) => (
        <React.Fragment>
          <a
            hidden={!hasPermission('mallproductpresale:update')}
            onClick={() => {
              this.setStateByTableColume(record, index);
              this.update();
            }}
          >
            <Tooltip title={<FormattedMessage id="ours.curd.list.edit" defaultMessage="编辑" />}>
              <Icon type="edit" />
            </Tooltip>
          </a>
          <Divider type="vertical" />
          <a
            hidden={!hasPermission('mallproductpresale:info')}
            onClick={() => {
              this.setStateByTableColume(record, index);
              this.view();
            }}
          >
            <Tooltip title={<FormattedMessage id="ours.curd.list.info" defaultMessage="查看" />}>
              <Icon type="info" />
            </Tooltip>
          </a>
        </React.Fragment>
      ),
    },
  ];

  constructor(props) {
    super(props);
    this.state = {
      showList: 1, //1:显示列表、2:显示新增
      formList: MallProductPreSale.getFormList(),
      selectedRows: [],
      selectedIds: [],
      selectedIndexs: [],
      editModalTitle: null,
      editModalType: null,
      editModel: null,
      editModelConfirmLoading: false,
      //其他属性下面书写
    };
  }

  // 筛选条件
  static getFormList = () => [
    {
      type: 'INPUT',
      field: 'productName',
      label: '商品名称',
      placeholder: '商品名称',
    },
    {
      type: 'SELECT',
      field: 'preSaleType',
      label: '预售类型',
      placeholder: '预售类型',
      list: [{ id: '', name: '请选择预售类型' }],
    },
    {
      type: 'SELECT',
      field: 'preEtdType',
      label: '发货类型',
      placeholder: '发货类型',
      list: [{ id: '', name: '请选择发货类型' }],
    },
  ];

  componentDidMount() {
    this.requestList();
    this.queryPreSaleTypeList();
    this.queryPreEtdTypeList();
  }

  componentWillUnmount() {
  }

  /**
   * 根据 formItem field 取值 查找formItem
   * @param formItemField obj的field字段
   * @returns 一个对象
   */
  findFormListItemByField = formItemField =>
    this.state.formList.find((value, index, array) => value.field === formItemField);

  query = fieldParams => {
    this.params = JSON.parse(JSON.stringify(Object.assign(this.params, fieldParams)));
    this.requestList();
  };

  add = () => {
    this.setState({
      editModalType: 'add',
      editModalTitle: formatMessage({id: 'ours.curd.list.create'}), //创建
      editModel: {
        preSaleType:0,
        preEtdType:0
      },
      showList: 2,
    });
  };

  update = () => {
    const {selectedRows, selectedIds, selectedIndexs} = this.state;
    if (!selectedRows) {
      uiUtils.showAlert(formatMessage({id: 'ours.curd.show-alert.select-please'}));
      return;
    }
    if (selectedRows.length > 1) {
      uiUtils.showAlert(formatMessage({id: 'ours.curd.show-alert.select-one-please'}));
      return;
    }
    this.setState({
      editModalType: 'update',
      editModalTitle: <FormattedMessage id="ours.curd.list.edit" defaultMessage="编辑"/>,
      editModel: selectedRows[0],
      showList: 2,
    });
    if(selectedRows[0].preEtdDays !== undefined){
      selectedRows[0].preEtdDays = `${selectedRows[0].preEtdDays}`;
    }
    this.getInfo(selectedRows[0].preSaleId);
  };

  view = () => {
    const {selectedRows, selectedIds, selectedIndexs} = this.state;
    if (!selectedRows) {
      uiUtils.showAlert(formatMessage({id: 'ours.curd.show-alert.select-please'}));
      return;
    }
    if (selectedRows.length > 1) {
      uiUtils.showAlert(formatMessage({id: 'ours.curd.show-alert.select-one-please'}));
      return;
    }
    this.setState({
      editModalType: 'view',
      editModalTitle: <FormattedMessage id="ours.curd.list.info" defaultMessage="查看"/>,
      editModel: selectedRows[0],
      showList: 2,
    });
    if (selectedRows[0].presSaleStart !== undefined && selectedRows[0].presSaleEnd !== undefined) {
      selectedRows[0].presSaleBetween = `${selectedRows[0].presSaleStart}至${selectedRows[0].presSaleEnd}`;
    }
    if (selectedRows[0].presBalanceStart !== undefined && selectedRows[0].presBalanceEnd !== undefined) {
      selectedRows[0].presBalanceBetween = `${selectedRows[0].presBalanceStart}至${selectedRows[0].presBalanceEnd}`;
    }
    this.getInfo(selectedRows[0].preSaleId);
  };

  del = () => {
    const selectedRows = this.state.selectedRows;
    const preSaleIds = [];
    for (let i = 0; i < selectedRows.length; i += 1) {
      preSaleIds.push(selectedRows[i].preSaleId);
    }

    uiUtils.showConfirm(formatMessage({id: 'ours.curd.show-alert.confirm-delete'}), () => {
      this.setState({
        loading: true,
      });
      requestPromise(`${getWebPath()}mallproductpresale/delete`, {
        method: 'POST',
        body: preSaleIds,
      }).then(res => {
        this.setState({
          loading: false,
        });
        if (res && res.code === 0) {
          uiUtils.showMessage(
            formatMessage({id: 'ours.curd.show-alert.operate-success'}),
            'success'
          );
          this.requestList();
        }
      });
    });
  };

  saveOrUpdate = () => {
    const editModalType = this.state.editModalType;
    //不能双向绑定，这里只能原对象、新对象进行合并.
    const mallProductPreSale = Object.assign(this.state.editModel, this.editForm.props.form.getFieldsValue());

    this.editForm.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        if (mallProductPreSale.preEtdType === 0) {
          mallProductPreSale.preEtdStart = mallProductPreSale.preEtdStart !== undefined ? `${mallProductPreSale.preEtdStart.format('YYYY-MM-DD HH:mm:ss')}` : mallProductPreSale.preEtdStart;
        }else{
          mallProductPreSale.preEtdStart = '';
        }
        if (mallProductPreSale.preSaleType === 1) {
          mallProductPreSale.presSaleStart = mallProductPreSale.presSaleBetween !== undefined ? `${mallProductPreSale.presSaleBetween[0].format('YYYY-MM-DD HH:mm:ss')}` : null;
          mallProductPreSale.presSaleEnd = mallProductPreSale.presSaleBetween !== undefined ? `${mallProductPreSale.presSaleBetween[1].format('YYYY-MM-DD HH:mm:ss')}` : null;
          mallProductPreSale.presBalanceStart = mallProductPreSale.presBalanceBetween !== undefined ? `${mallProductPreSale.presBalanceBetween[0].format('YYYY-MM-DD HH:mm:ss')}` : null;
          mallProductPreSale.presBalanceEnd = mallProductPreSale.presBalanceBetween !== undefined ? `${mallProductPreSale.presBalanceBetween[1].format('YYYY-MM-DD HH:mm:ss')}` : null;
        }else{
          mallProductPreSale.presSaleStart = null;
          mallProductPreSale.presSaleEnd = null;
          mallProductPreSale.presBalanceStart = null;
          mallProductPreSale.presBalanceEnd = null;
        }

        // submit the values
        const url = mallProductPreSale.preSaleId == null ? '/mallproductpresale/save' : '/mallproductpresale/update';
        //对象删除一个属性
        //delete mallProductPreSale.xxxxPros;

        this.setState({
          editModelConfirmLoading: true,
        });
        requestPromise(getWebPath() + url, {
          method: 'POST',
          body: mallProductPreSale,
        }).then(res => {
          this.setState({
            editModelConfirmLoading: false,
          });
          if (res && res.code === 0) {
            uiUtils.showMessage(
              formatMessage({id: 'ours.curd.show-alert.operate-success'}),
              'success'
            );
            this.setState({
              showList: 1,
            });

            //新增重新置为第一页
            if (!mallProductPreSale.preSaleId) {
              this.params.page = 1;
            }
            this.requestList();
          }
        });
      }
    });
  };

  getInfo = preSaleId => {
  };

  setStateByTableColume = (record, index) => {
    this.state = {
      ...this.state,
      selectedRows: [record],
      selectedIds: [record.preSaleId],
      selectedIndexs: [index],
    };
  };

  //========其他所有的处理方法，请在按照约定进行处理==========

  /**
   * 表格 筛选和排序 回调
   */
  filtersSorterChange = tableParams => {
    this.params = JSON.parse(JSON.stringify(Object.assign(this.params, tableParams)));
    this.requestList();
  };

  requestList = () => {
    requestLists(this, `${getWebPath()}mallproductpresale/listVo`, this.params);
  };

  queryPreSaleTypeList = () => {
    const newRecommended = [
      { id: '', name: '请选择预售类型' },
      { id: '0', name: '全款预售' },
      { id: '1', name: '定金预售' },
    ];
    const formItem = this.findFormListItemByField('preSaleType');
    formItem.list = newRecommended;
  };

  queryPreEtdTypeList = () => {
    const newRecommended = [
      { id: '', name: '请选择发货类型' },
      { id: '0', name: '指定日期发货' },
      { id: '1', name: 'X天后发货' },
    ];
    const formItem = this.findFormListItemByField('preEtdType');
    formItem.list = newRecommended;
  };

  vShow = showListNum => ({display: this.state.showList === showListNum ? 'block' : 'none'});

  render() {
    const btnStyle = {
      style: {
        marginLeft: 10,
        marginTop: 10,
      },
      disabled: this.state.selectedIndexs.length <= 0,
    };

    /* eslint-disable react/jsx-no-bind */
    return (
      <PageHeaderWrapper title="">
        <Card
          bordered={false}
          style={{...this.vShow(1)}}
          className={styles.oursCard}
          bodyStyle={{padding: '20px'}}
        >
          <BaseForm
            formList={this.state.formList}
            loading={this.state.loading}
            filterSubmit={this.query}
          />

          <Fragment>
            <Button
              type="primary"
              icon="plus"
              onClick={this.add}
              hidden={!hasPermission('mallproductpresale:save')}
            >
              <FormattedMessage id="ours.curd.list.add" defaultMessage="新增"/>
            </Button>
            <Button
              type="danger"
              icon="delete"
              {...btnStyle}
              onClick={this.del}
              hidden={!hasPermission('mallproductpresale:delete')}
            >
              <FormattedMessage id="ours.curd.list.delete" defaultMessage="删除"/>
            </Button>
          </Fragment>

          <div className="content-wrap">
            <ETable
              onSelectRow={uiUtils.onSelectRow.bind(this)}
              primaryKey="pre_sale_id"
              selectedIndexs={this.state.selectedIndexs}
              selectedRows={this.state.selectedRows}
              selectedIds={this.state.selectedIds}
              onChange={this.filtersSorterChange}
              columns={this.columns}
              dataSource={this.state.list}
              pagination={this.state.pagination}
              loading={this.state.loading}
              scroll={{x: 1200}}
            />
          </div>
        </Card>

        <BackTop/>

        <Spin spinning={this.state.editModelConfirmLoading} delay={10}>
          {//返回null,这里对不用的组件进行销毁
            this.state.showList === 1 ? null : (
              <Card
                title={this.state.editModalTitle}
                bordered={false}
                actions={[
                  <div>
                    <React.Fragment>
                      <Button
                        type="primary"
                        hidden={this.state.editModalType === 'view'}
                        style={{marginRight: '18px'}}
                        onClick={this.saveOrUpdate}
                      >
                        <FormattedMessage id="ours.curd.add.save" defaultMessage="保存"/>
                      </Button>
                      <Button
                        style={{marginRight: '18px'}}
                        onClick={() => {
                          this.editForm.props.form.resetFields();
                          this.setState({showList: 1});
                        }}
                      >
                        <FormattedMessage id="ours.curd.add.back" defaultMessage="返回"/>
                      </Button>
                    </React.Fragment>
                  </div>,
                ]}
                style={{...this.vShow(2)}}
                bodyStyle={{padding: '20px'}}
                ref={node => {
                  this.container = node;
                }}
              >
                <EditForm
                  type={this.state.editModalType}
                  model={this.state.editModel}
                  wrappedComponentRef={inst => {
                    this.editForm = inst;
                  }}
                />
              </Card>
            )}
        </Spin>
      </PageHeaderWrapper>
    );
  }
}

export default MallProductPreSale;

/**
 *  新增、编辑、复制、查看的Form
 */

/* eslint react/no-multi-comp:0 */
class EditForm extends React.Component {

  static propTypes = {
    type: PropTypes.string, //form类型，可选值：add（增加）、update（修改）、copy（复制）、view（查看）、
    model: PropTypes.object, //数据模型model，对应后台的model
  };

  static defaultProps = {
    type: '', //表单布局数组
    model: null,
  };

  constructor(props) {
    super(props);
    this.state = {};
    this.handleSearch();
  }

  /**
   * 生命周期-属性发生变化...componentWillReceiveProps
   * 这里的nextProps，可以获取到所有的属性。
   * 目前没用，因为 dialog 每次都被销毁了
   */
  componentWillReceiveProps(nextProps) {}

  getPropsByKey = prop => {
    const model = this.props.model || {};
    const finalModel = Object.assign(model, this.props.form.getFieldsValue());
    return finalModel[prop];
  };

  handleSearch = () => {
    requestPromise(
      `${getWebPath(`/mailproduct/list?status=2&not_IN_pre_sale=1`)}`,
      {
        method: 'GET',
      }
    ).then(res => {
      if (res && res.code === 0) {
        const datas = res.page.list || [];
        const results = [];
        datas.forEach((r, index) => {
          results.push(
            <Option key={r.id} value={r.id}>
              {r.productName}
            </Option>
          );
        });
        this.setState({
          productInfo: results,
        });
      }
    });
  };

  render() {
    const type = this.props.type; //编辑是：新增（add）、编辑(edit)、复制(copy)、还是查看(view)
    const model = this.props.model || {};
    const {form, form: {getFieldDecorator, getFieldValue, setFieldsValue}} = this.props;
    const formItemLayout = {
      labelCol: {span: 5},
      wrapperCol: {span: 18}, //5+19=24,少一个栅格
    };
    const colSpanLayout = {md: 12, sm: 24}; //每一col跨?列
    const rowGutterPxLayout = {md: 24, sm: 16}; //col之间的间隔?px
    const inputCodeDisabled = {
      disabled: type === 'update',
    };
    const result = [];
    if (type === 'update') {
      result.push(
        <Option key={model.productId} value={model.productId}>
          {model.productName}
        </Option>
      );
    }
    //校验文档：https://ant.design/components/form-cn/#%E6%A0%A1%E9%AA%8C%E8%A7%84%E5%88%99
    return (
      <Form layout="horizontal">
        <Row gutter={{...rowGutterPxLayout}}>
          <Col {...colSpanLayout}>
            <FormItem label="商品名称" {...formItemLayout}>
              {type === 'view'
                ? model.productName
                : getFieldDecorator('productId', {
                  initialValue: model.productId,
                  rules: [
                    {
                      required: true,
                      message: '商品名称必选',
                    },
                  ],
                })(
                  <Select
                    style={{ width: 330 }}
                    showSearch
                    placeholder="请输入商品名称"
                    optionFilterProp="children"
                    notFoundContent={null}
                    //onSearch={this.handleSearch}
                  >
                    {result}
                    {this.state.productInfo}
                  </Select>
                )}
            </FormItem>
          </Col>
          <Col {...colSpanLayout}>
            <FormItem label="预售类型" {...formItemLayout}>
              {type === 'view'
                ? model.preSaleType === 0 ? '全款预售' : '定金预售'
                : getFieldDecorator('preSaleType', {
                  initialValue: model.preSaleType,
                  rules: [
                    {
                      required: true,
                      message: '预售类型必填',
                    },
                  ],
                })(
                  <RadioGroup
                    onChange={e => {
                      model.preSaleType = e.target.value;
                    }}
                  >
                    <Radio value={0}>全款预售</Radio>
                    <Radio value={1}>定金预售</Radio>
                  </RadioGroup>
                )}
            </FormItem>
          </Col>
          <Col {...colSpanLayout}>
            <FormItem label="发货时间类型" {...formItemLayout}>
              {type === 'view'
                ? model.preEtdType === 0 ? '指定日期发货' : 'X天后发货'
                : getFieldDecorator('preEtdType', {
                  initialValue: model.preEtdType,
                  rules: [
                    {
                      required: true,
                      message: '发货时间类型必填',
                    },
                  ],
                })(
                  <RadioGroup
                    onChange={e => {
                      model.preEtdType = e.target.value;
                    }}
                  >
                    <Radio value={0}>指定日期发货</Radio>
                    <Radio value={1}>X天后发货</Radio>
                  </RadioGroup>
                )}
            </FormItem>
          </Col>
          {
            model.preSaleType === 1 &&
              <div>
                <Col {...colSpanLayout}>
                  <FormItem label="定金支付时间" {...formItemLayout}>
                    {type === 'view'
                      ? model.presSaleBetween
                      : getFieldDecorator('presSaleBetween', {
                        initialValue: [
                          model.presSaleStart === undefined || model.presSaleStart === ''? '': moment(model.presSaleStart, 'YYYY-MM-DD HH:mm:ss'),
                          model.presSaleEnd === undefined || model.presSaleEnd === ''? '': moment(model.presSaleEnd, 'YYYY-MM-DD HH:mm:ss')
                        ],
                        rules: [
                          {
                            required: true,
                            message: '定金支付时间必选',
                          },
                        ],
                      })(
                        <RangePicker
                          style={{ width: 330 }}
                          showTime
                          placeholder={['请选择定金开始时间', '请选择定金结束时间']}
                          defaultValue={[
                            model.presSaleStart === undefined || model.presSaleStart === ''? '': moment(model.presSaleStart, 'YYYY-MM-DD HH:mm:ss'),
                            model.presSaleEnd === undefined || model.presSaleEnd === ''? '': moment(model.presSaleEnd, 'YYYY-MM-DD HH:mm:ss')
                          ]}
                        />
                      )}
                  </FormItem>
                </Col>
                <Col {...colSpanLayout}>
                  <FormItem label="尾款支付时间" {...formItemLayout}>
                    {type === 'view'
                      ? model.presBalanceBetween
                      : getFieldDecorator('presBalanceBetween', {
                        initialValue: [
                          model.presBalanceStart === undefined || model.presBalanceStart === ''? '': moment(model.presBalanceStart, 'YYYY-MM-DD HH:mm:ss'),
                          model.presBalanceEnd === undefined || model.presBalanceEnd === ''? '': moment(model.presBalanceEnd, 'YYYY-MM-DD HH:mm:ss')
                        ],
                        rules: [
                          {
                            required: true,
                            message: '尾款支付时间必选',
                          },
                        ],
                      })(
                        <RangePicker
                          style={{ width: 330 }}
                          showTime
                          placeholder={['请选择尾款开始时间', '请选择定金结束时间']}
                          defaultValue={[
                            model.presBalanceStart === undefined || model.presBalanceStart === ''? '': moment(model.presBalanceStart, 'YYYY-MM-DD HH:mm:ss'),
                            model.presBalanceEnd === undefined || model.presBalanceEnd === ''? '': moment(model.presBalanceEnd, 'YYYY-MM-DD HH:mm:ss'),
                          ]}
                        />
                      )}
                  </FormItem>
                </Col>
              </div>
          }
          {
            model.preEtdType === 0 &&
            <Col {...colSpanLayout}>
              <FormItem label="指定日期发货" {...formItemLayout}>
                {type === 'view'
                  ? model.preEtdStart
                  : getFieldDecorator('preEtdStart', {
                    initialValue: model.preEtdStart === undefined || model.preEtdStart === ''? '': moment(model.preEtdStart, 'YYYY-MM-DD HH:mm:ss'),
                    rules: [
                      {
                        required: true,
                        message: '指定日期发货必填',
                      },
                    ],
                  })(
                    <DatePicker
                      style={{ width: 330 }}
                      showTime
                      placeholder="请选择指定日期发货"
                      defaultValue={model.preEtdStart === undefined || model.preEtdStart === ''? '': moment(model.preEtdStart, 'YYYY-MM-DD HH:mm:ss')
                      }
                    />
                  )}
              </FormItem>
            </Col>
          }
          {
            model.preEtdType === 1 &&
            <Col {...colSpanLayout}>
              <FormItem label="X天后发货" {...formItemLayout}>
                {type === 'view'
                  ? model.preEtdDays
                  : getFieldDecorator('preEtdDays', {
                    initialValue: model.preEtdDays,
                    rules: [
                      {
                        required: true,
                        message: 'X天后发货必填',
                      },
                      {
                        max: 9,
                        message: '最长9个字符',
                      },
                      rulesReg('plus'),
                    ],
                  })(
                    <Input
                      type="text"
                      autocomplete="off"
                      placeholder="请输入"
                      style={{ width: 330 }}
                    />
                  )}
              </FormItem>
            </Col>
          }
          {
            model.preSaleType === 1 &&
            <Col {...colSpanLayout}>
              <FormItem label="尾款定金比例" {...formItemLayout}>
                {type === 'view'
                  ? model.presDepositRate
                  : getFieldDecorator('presDepositRate', {
                    initialValue: model.presDepositRate,
                    rules: [
                      {
                        required: true,
                        message: '尾款定金比例必选',
                      },
                      rulesReg('nozero'),
                      rulesReg('plusnums2'),
                    ],
                  })(
                    <Input
                      style={{ width: 330 }}
                      type="text"
                      autocomplete="off"
                      placeholder="尾款定金比例，如：0.01"
                    />
                  )}
              </FormItem>
            </Col>
          }
        </Row>
      </Form>
    );
  }
}

/* eslint-disable no-class-assign */
//无更多的绑定， 请用 @Form.create() 注解替换
EditForm = Form.create({})(EditForm);
